
{layout name="layout/layout" /}
<style>
	.re{
		color: red;
	}
</style>
<div class="king-content-wrap">
	<div class="king-layout1-content" style="margin-top: 0; margin-left: 0px;">
		<ol class="breadcrumb">
			<li><span>添加分期详情</span></li>
			<li><span style="color: red">{$user_name}</span></li>
			<li><span>{$re.loan_type}</span></li>
			<li><span>{$re.loan_pingtai}</span></li>
			<li><span>{$re.repayment_type}</span></li>

		</ol>
		<div class="panel panel-default m20" style="width:30%;">
			<div class="panel-body">
			<table style="width: 100%" class="table table-striped">
				<tr style="background-color: #f5f5f5;font-size: 17px">
					<td>期数</td>
					<td>还款金额（元）</td>
					<td>还款状态</td>
					<td>操作</td>
				</tr>
				{foreach $date as $vo}


				<tr>
					<td>{$vo.repayment_qishu}</td>
					<td>{$vo.repayment_money}元</td>
					<td id ="zhuangitai{$vo.repayment_id}">
						{if condition="$vo.repayment_zhuangtai == 1"}
						<span style="color: #00a0e9">已还</span>
						{else /}
						<span style="color: red">未还</span>
						{/if}

					</td>
					<td>
						<a href="#" class="zhuangtai" repaymentid="{$vo.repayment_id}" zhuangtai="{$vo.repayment_zhuangtai}">点击改变状态 </a>
						<a href="#" class="money" repaymentid="{$vo.repayment_id}">修改金额</a>
					</td>
				</tr>
				{/foreach}

			</table>



			</div>
		</div>
	</div>
</div>
<script type="text/javascript" src="/static/layer/layer.js"></script>
<script>
	$('.zhuangtai').click(function(){
		var repaymentid = $(this).attr('repaymentid');

		$.post('{:Url("admin/repayment/editzhuangtai")}',{repayment_id:repaymentid},function(data){

			if(data == '1'){

				$('#zhuangitai'+repaymentid).html('<span style="color: #00a0e9">已还</span>');
			}else {

				$('#zhuangitai'+repaymentid).html('<span style="color: red">未还</span>');
			}

		});


	});
	 $('.money').click(function(){
		 var repayment_id  = $(this).attr('repaymentid');
		 layer.prompt({title: '输入金额（单位:元）', formType: 3}, function(text, index){

			 if(!isNaN(text)){
				 $.post('{:Url("admin/repayment/editmoney")}',{repayment_id:repayment_id,money:text},function(data){

					alert(data);
					 window.location.reload();
				 });
			 }else{
				 layer.alert("输入错误！");
			 }

		 });
	 });
</script>




